package flc.ast.adapter;


import android.graphics.Color;

import androidx.annotation.NonNull;

import com.blankj.utilcode.util.ConvertUtils;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyAudioBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;
import stark.common.basic.media.bean.AudioBean;
import stark.common.basic.utils.TimeUtil;

public class PriAudioAdapter extends StkProviderMultiAdapter<MyAudioBean> {

    public boolean hasQuery;
    public String keyWord;

    public PriAudioAdapter() {
        addItemProvider(new StkSingleSpanProvider(126));
        addItemProvider(new PriAudioProvider());
    }

    private class PriAudioProvider extends BaseItemProvider<MyAudioBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_audio;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyAudioBean bean) {
            baseViewHolder.setText(R.id.tvSelAudioItemName, bean.getName());
            baseViewHolder.setText(R.id.tvSelAudioItemSize, ConvertUtils.byte2FitMemorySize(bean.getSize(), 0));
            baseViewHolder.setText(R.id.tvSelAudioItemDuration, TimeUtil.getMmss(bean.getDuration()));
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.llSelAudioItem).setBackgroundColor(Color.parseColor("#1A2D53FF"));
            } else {
                baseViewHolder.getView(R.id.llSelAudioItem).setBackgroundColor(0);
            }
        }
    }

}
